Ext.define('App.kpiconfiguration.viewmodel.KpiConfigurationViewModel', {
    extend: 'Ext.app.ViewModel',
    alias: 'viewmodel.kpi_configuration_viewmodel',
    requires: ['App.kpiconfiguration.model.KpiConfigurationModel'],
    data: {
        selectionColumns: [{
            header: 'ID',
            dataIndex: 'id',
            hidden: true
        }, {
            header: 'KPI名称',
            dataIndex: 'field'
        }, {
            header: '类型',
            dataIndex: 'dataType'
        }, {
            header: '描述',
            dataIndex: 'description'
        }, {
            header: '创建者',
            dataIndex: 'creator'
        }],
        columns: [{
            header: 'ID',
            dataIndex: 'id',
            hidden: true
        }, {
            header: 'KPI名称',
            dataIndex: 'field',
            flex:3
        }, {
            header: '数据类型',
            dataIndex: 'dataType',
            flex:1
        }, {
            header: '计算表达式',
            dataIndex: 'expression',
            flex:4
        }, {
            header: '日期格式',
            dataIndex: 'format',
            flex:1
        }, {
            header: '格式化方式',
            dataIndex: 'formatter',
            flex:1
        }, {
            header: '点灯类型',
            dataIndex: 'judgmentStateMode',
            flex:1
        },{
            header: '度量类型',
            dataIndex: 'metricType',
            flex:1
        }, {
            xtype: 'numbercolumn',
            header: '显示宽度(px)',
            dataIndex: 'width',
            flex:1
        }, {
            header: '描述',
            dataIndex: 'description'
        }, {
            header: '创建者',
            dataIndex: 'creator',
            flex:1
        }, {
            header: '只读',
            dataIndex: 'readOnly',
            flex:1,
            renderer: function (v, m, r) {
                return v == true ? '<span style="color: red;">是</span>' : '否'
            }
        }, {
            header: '关联报表',
            dataIndex: 'id',
            flex:1,
            renderer: function (v, m, r) {
                return '<a onclick="javascript:;" href="javascript:;">查看</a>';
            }
        }],
        search: {
            simpleSearch: true,
            advancedSearch: true,
            fields: [{
                "field": "field",
                "name": "KPI名称",
                vtype: 's',
                opt: 'like'
            }, {
                "field": "dataType",
                "name": "类型",
                vtype: 's',
                opt: 'like'
            }]
        }
    },
    stores: {
        Query: {
            autoLoad: false,
            model: 'App.kpiconfiguration.model.KpiConfigurationModel',
            pageSize: 25,
            remoteSort: true,
            proxy: {
                type: 'majax',
                url: 'kpiconfiguration/query_distinct_sample',
                reader: {
                    type: 'json',
                    rootProperty: 'data',
                    totalProperty: 'total'
                }
            }
        }
    }
});